<%@page import="java.util.HashMap"%>
<%@page import="QRCG.DatabaseManager"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Statistics</title>
<link href="index.css" rel="stylesheet" type="text/css" />
</head>
<%@ include file="header.jsp"%>

<%
	DatabaseManager dbManager = new DatabaseManager();
	dbManager.connect();
%>
<body>

<div class="information-text">
	<table align="center">
		<tr>
			<td></td>
		</tr>
	</table>
</div>

<div id="page">
<div id="page-bgtop">

<div id="statistics-page">
	<div class="statistics-fragment" id="statistics-fragment1">
		<div class="statistics-label">
			<div class="statistics-label-text">Most Game Winners</div>
		</div>
		
		<div class="statistics-entry">
			<table align="center" class="statistics-table">
				<thead>
					<tr>
						<th class="statistics-table-head">Nickname</th>
						<th class="statistics-table-head">Games Finished</th>
					</tr>
				</thead>
				<%
					for (HashMap<String, Object> row : dbManager.getMostWinnerUsers(5)) {
				%>
				<tr>
					<td class="statistics-left-field"><%=row.get("nickname")%></td>
					<td class="statistics-right-field"><%=row.get("games_finished")%></td>
				</tr>
				<%
					}
				%>
			</table>
		</div>
	</div>
	
	<div class="statistics-fragment" id="statistics-fragment2">
		<div class="statistics-label">
			<div class="statistics-label-text">Users Created Games Most</div>
		</div>
		<div class="statistics-entry">
			<table align="center" class="statistics-table">
				<thead>
					<tr>
						<th class="statistics-table-head">Nickname</th>
						<th class="statistics-table-head">Games Created</th>
					</tr>
				</thead>
				<%
					for (HashMap<String, Object> row : dbManager.getUsersCreatedGamesMost(5)) {
				%>
				<tr>
					<td class="statistics-left-field"><%=row.get("nickname")%></td>
					<td class="statistics-right-field"><%=row.get("game_count")%></td>
				</tr>
				<%
					}
				%>
			</table>
		</div>
	</div>
	
	<div class="statistics-fragment" id="statistics-fragment3">
		<div class="statistics-label">
			<div class="statistics-label-text">All Time Top Rated Games</div>
		</div>
		<div class="statistics-entry">				
			<table align="center" class="statistics-table">
				<thead>
					<tr>
						<th class="statistics-table-head">Game Name</th>
						<th class="statistics-table-head">Rating</th>
					</tr>
				</thead>
				<%
					for (HashMap<String, Object> row : dbManager.getTopRatedGames(5)) {
				%>
				<tr>
					<td class="statistics-left-field"><%=row.get("name")%></td>
					<td class="statistics-right-field"><%=row.get("rating")%></td>
				</tr>
				<%
					}
				%>
			</table>
		</div>
	</div>
	
	<div class="statistics-fragment" id="statistics-fragment4">
		<div class="statistics-label">
			<div class="statistics-label-text">Users Registered to Games Most</div>
		</div>
		
		<div class="statistics-entry">
			<table align="center" class="statistics-table">
				<thead>
					<tr>
						<th class="statistics-table-head">Nickname</th>
						<th class="statistics-table-head">Games Registered</th>
					</tr>
				</thead>
				<%
					for (HashMap<String, Object> row : dbManager.getUsersRegisteredToGamesMost(5)) {
				%>
				<tr>
					<td class="statistics-left-field"><%=row.get("nickname")%></td>
					<td class="statistics-right-field"><%=row.get("game_count")%></td>
				</tr>
				<%
					}
				%>
			</table>
		</div>
	</div>	
			
	<div class="statistics-fragment" id="statistics-fragment5">
		<div class="statistics-label">
			<div class="statistics-label-text">Games With Most Users</div>
		</div>
		<div class="statistics-entry">
			<table align="center" class="statistics-table">
				<thead>
					<tr>
						<th class="statistics-table-head">Game Name</th>
						<th class="statistics-table-head">Players Registered</th>
					</tr>
				</thead>
				<%
					for (HashMap<String, Object> row : dbManager.getGamesWithMostPlayers(5)) {
				%>
				<tr>
					<td class="statistics-left-field"><%=row.get("name")%></td>
					<td class="statistics-right-field"><%=row.get("player_count")%></td>
				</tr>
				<%
					}
				%>
			</table>
		</div>
	</div>
	
</div>

</div>
</div>
<div style="clear: both;">&nbsp;</div>

</body>

<%@ include file="footer.jsp"%>